using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection.Emit;

namespace OR.Reuse.Reflection
{
	class TypeUtility
	{
		public static Type GetGenericType( string genericClass, string[] typeList )
		{
			Type vReturn = null;

			// get the open generic type
			Type genericType = Type.GetType( genericClass );

			// construct the array of generic type parameters
			Type[] typeArgs = new Type[ typeList.Length ];

			for ( int i = 0; i < typeList.Length; i++ )
			{
				typeArgs[ i ] = Type.GetType( typeList[ i ] );
			}
			
			// get the closed generic type
			vReturn = genericType.MakeGenericType( typeArgs );

			return vReturn;
		}
	}
}
